package com.lemon.core.log.config;

import com.lemon.core.log.annotation.EnableOperateLog;
import com.lemon.core.log.aspect.OperateLogAspect;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 日志自动配置
 * <p>
 * 启动条件：
 * 1，存在web环境
 * 配合使用{@link EnableOperateLog}灵活配置
 *
 * @author pan
 * @since 2019-09-12
 */
@EnableAsync
@AllArgsConstructor
@ConditionalOnWebApplication
public class LogAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public OperateLogAspect operateLogAspect() {
        return new OperateLogAspect();
    }
}
